import React from 'react';
import ReactDOM from 'react-dom';
import './index.css'

function Hooks(props){
	const [count, setCount] = React.useState(0);
	
	  React.useEffect(() => {
		  console.log('执行useEffect')
			document.title = `You clicked ${count} times`;
	  },[count]);
	
	  return (
	    <div>
	      <p>You clicked {count} times</p>
	      <button onClick={() => setCount(count + 1)}>Click me</button>
	    </div>
	  );
	
	
	
	// const [temp, setTemp] = React.useState(5);
	
	//   const log = () => {
	//     setTimeout(() => {
	//       console.log("3 秒前 temp = 5，现在 temp =", temp);
	//     }, 3000);
	//   };
	
	//   return (
	//     <div
	//       onClick={() => {
	//         log();
	//         setTemp(3);
	//         // 3 秒前 temp = 5，现在 temp = 5
	//       }}
	//     >
	//       xyz
	//     </div>
	//   );
}

export default Hooks